{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9aaa448c-395c-415c-9a1b-06bf4c032c0d",
   "metadata": {},
   "source": [
    "## 1. 打印输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "955b3c83-4dd4-4cb0-8043-14cc32fe6259",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "我用Python1\n",
      "我用Python2\n",
      "我用Python3\n"
     ]
    }
   ],
   "source": [
    "print('我用Python1')\n",
    "print('我用Python2')\n",
    "print('我用Python3')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4d71962c-2e0f-4470-91e5-475e749dc08e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'我用Python3'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'我用Python1'\n",
    "'我用Python2'\n",
    "'我用Python3'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "c44d212d-6ca6-489b-a079-5cdbbf5d8c97",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x变量的值= 123 ；y变量的值= 456\n"
     ]
    }
   ],
   "source": [
    "x = 123\n",
    "y = 456\n",
    "print('x变量的值=', x, '；y变量的值=', y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c1f04abc-852b-4d4a-a7d5-5b2d4a31b86e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "d3f9b507-629f-45ea-ba8d-1d21b6a1648d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 2 3 4 5 6\n"
     ]
    }
   ],
   "source": [
    "print(1, 2, 3, 4, 5, 6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "a809a4df-98b1-4b38-bc3e-5858fa8b5662",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1、2、3、4、5、6\n"
     ]
    }
   ],
   "source": [
    "print(1, 2, 3, 4, 5, 6, sep='、')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9bdd381b-2eba-4def-8ff8-e1d937d26d9f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "123456\n"
     ]
    }
   ],
   "source": [
    "print(1, 2, 3, 4, 5, 6, sep='')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4b16da0f-b46c-4664-a9ef-7a70fba040cc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "26e6fb9c-8ab0-461a-9598-35e8c0379d2f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x变量的值=123；y变量的值=456\n"
     ]
    }
   ],
   "source": [
    "x = 123\n",
    "y = 456\n",
    "print('x变量的值=', x, '；y变量的值=', y, sep='')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "f6b9f232-2ca0-40b1-8260-cba708a1eb01",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x变量的值=123\n",
      "y变量的值=456\n"
     ]
    }
   ],
   "source": [
    "x = 123\n",
    "y = 456\n",
    "\n",
    "print('x变量的值=', x, sep='')\n",
    "print('y变量的值=', y, sep='')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5ce696c5-7c5d-4d39-b375-c06213c7a055",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e8b03bb1-9788-47e3-98fe-441020ec4743",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x变量的值=123；y变量的值=456\n"
     ]
    }
   ],
   "source": [
    "x = 123\n",
    "y = 456\n",
    "\n",
    "print('x变量的值=', x, sep='', end='；')\n",
    "print('y变量的值=', y, sep='')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "59f11cc9-ba71-4841-a563-ad906b7ff91c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "e33fd8f3-8cb6-41ce-a53b-c305f6de2daf",
   "metadata": {},
   "source": [
    "<br>\n",
    "\n",
    "## 2. 格式化字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "a866afb8-887b-41c9-a506-9f581221f7c4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x变量的值=123；y变量的值=456\n"
     ]
    }
   ],
   "source": [
    "x = 123\n",
    "y = 456\n",
    "\n",
    "print(f'x变量的值={x}；y变量的值={y}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "d81b4d9d-5126-4f24-b891-7da20da155fa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len('张三                  ')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ad4b4f66-c714-4338-9204-f636ac564dfc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "a4066aca-1cc7-4dc8-b160-93348bd8787f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1. 本人（张三                  ）志愿参加活动\n",
      "2. 本人（         张三         ）志愿参加活动\n",
      "3. 本人（                  张三）志愿参加活动\n",
      "4. 本人（张三                  ）志愿参加活动\n",
      "5. 本人（*********张三*********）志愿参加活动\n"
     ]
    }
   ],
   "source": [
    "name = '张三'\n",
    "print(f'1. 本人（{name:20}）志愿参加活动')\n",
    "print(f'2. 本人（{name:^20}）志愿参加活动')\n",
    "print(f'3. 本人（{name:>20}）志愿参加活动')\n",
    "print(f'4. 本人（{name:<20}）志愿参加活动')\n",
    "print(f'5. 本人（{name:*^20}）志愿参加活动')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "ade238a0-19aa-4a26-962b-a735d960a27a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x变量值是（                 123）\n"
     ]
    }
   ],
   "source": [
    "x = 123\n",
    "print(f\"x变量值是（{x:20}）\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b8d0b731-37de-4dd8-b8ec-f8c3d857303c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "fd5648d9-dfb5-4a7e-bb2d-36d91cf2caee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x变量值是（_________________123）\n"
     ]
    }
   ],
   "source": [
    "x = 123\n",
    "print(f\"x变量值是（{x:_>20}）\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5b12d5e1-5663-463a-ad52-0842443aa567",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "41679377-be1b-4f7c-a5c4-1fe6e655cfce",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "30185c2e-e0a4-467b-a7ac-a23f8d318dfc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x变量值是（3.67）\n"
     ]
    }
   ],
   "source": [
    "x = 11 / 3\n",
    "print(f\"x变量值是（{x:.2f}）\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "523bbf71-b2f9-474e-82f7-9cae765b5eed",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "6ab583a8-b62a-4787-b08f-7c4ba527fb5b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x变量值是（3.67e+00）\n"
     ]
    }
   ],
   "source": [
    "x = 11 / 3\n",
    "print(f\"x变量值是（{x:.2e}）\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cd471269-aae7-41c1-b741-5c418934d67b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "2ab4a15a-dab2-4aa7-8077-8dd09d644af6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x变量值是（3.67E+00）\n"
     ]
    }
   ],
   "source": [
    "x = 11 / 3\n",
    "print(f\"x变量值是（{x:.2E}）\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8eb1ab45-2e71-4969-bef1-4968466ea82a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
